﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Models.Base;
using Models.Extension;
using Common.CacheCleient;
using WFI.DAL;

namespace WFI.BLL
{
    public class baseAccessManage
    {
        public static readonly baseAccessManage _baseAccessManage = new baseAccessManage();

        private static CacheEntity<UserInfo> _userList = new CacheEntity<UserInfo>(true);
        private static CacheEntity<GroupInfo> _GroupInfoList = new CacheEntity<GroupInfo>(true);
        private static CacheEntity<UserLinkGroup> _UserLinkGroupList = new CacheEntity<UserLinkGroup>(true);
        private static CacheEntity<Function> _FunctionList = new CacheEntity<Function>(true);
        private static CacheEntity<GroupLinkFunction> _GroupLinkFunctionList = new CacheEntity<GroupLinkFunction>(true);
        /// <summary>
        /// 得到所有用户信息
        /// </summary>
        /// <returns></returns>
        public List<UserInfo> GetAllUserInfo()
        {
            return cacheManage.GetDataWithCache(_userList, baseAccessService._baseAccessService.GetAllUserInfo);
        }

        public bool InsertUserInfo()
        {
            _userList.isQuery = true;
            return true;
        }


        /// <summary>
        /// 得到所有组
        /// </summary>
        /// <returns>所有组</returns>
        public List<GroupInfo> GetAllGroupInfo()
        {
            return cacheManage.GetDataWithCache(_GroupInfoList, baseAccessService._baseAccessService.GetAllGroupInfo);
        }

        /// <summary>
        /// 所有用户与组的关系
        /// </summary>
        /// <returns></returns>
        public List<UserLinkGroup> GetAllUserLinkGroup()
        {
            return cacheManage.GetDataWithCache(_UserLinkGroupList, baseAccessService._baseAccessService.GetAllUserLinkGroup);
        }

        /// <summary>
        /// 所有功能
        /// </summary>
        /// <returns></returns>
        public List<Function> GetAllFunction()
        {
            return cacheManage.GetDataWithCache(_FunctionList, baseAccessService._baseAccessService.GetAllFunction);
        }

        /// <summary>
        /// 组对应功能
        /// </summary>
        /// <returns></returns>
        public List<GroupLinkFunction> GetAllGroupLinkFunction()
        {
            return cacheManage.GetDataWithCache(_GroupLinkFunctionList, baseAccessService._baseAccessService.GetAllGroupLinkFunction);
        }
    }
}
